package com.igeek.dao;

import com.igeek.domain.Category;
import com.igeek.utils.JDBCTools;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author jerryHe
 * @create 2019-10-10 8:59
 */
public class CategoryDao{
    QueryRunner qr = new QueryRunner(JDBCTools.getDataSource());
    String sql ="";
    public List<Category> findAllCategories() {
        sql = "select * from category";
        try {
            return qr.query(sql,new BeanListHandler<>(Category.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
